<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增团长')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teamYl-add">
            <h4 class="form-header h4" >团队编号信息</h4>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">团队编号：</label>
                    <div class="col-sm-8">
                        <input name="teamYlId" class="form-control" th:value="${teamCode}"  type="text" required readonly>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4" >团长信息</h4>
            <div class="row">
                <div class="form-group">
                    <label class="col-sm-3 control-label  is-required">团长代理编号：</label>
                    <div class="col-sm-8">
                        <input name="leaderAgentNum" onclick="selectTeamView()" readonly id="teamAgentNum" type="text" class="form-control" required>
                        <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">采购机器数量：</label>
                    <div class="col-sm-8">
                        <input name="posNum" class="form-control" placeholder="开团直采(团长及直属团员直采累计10000)"  type="number" required >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">团长代理名称：</label>
                    <div class="col-sm-8">
                        <input name="leaderAgentName" class="form-control" id="teamAgentName" type="text" required readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">团长账号：</label>
                    <div class="col-sm-8">
                        <input name="loginName" class="form-control" type="text" required >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">团长密码：</label>
                    <div class="col-sm-8">
                        <input name="password" class="form-control" type="password" required >
                    </div>
                </div>
                <div class="form-group" style="display: none;">
                    <label class="col-sm-3 control-label">团类型：</label>
                    <div class="col-sm-8">
                        <select name="teamType" class="form-control m-b" onchange="selectOnchange(this)">
                            <option value="1">老团</option>
                            <option value="2">新团</option>
                        </select>
                    </div>
                </div>
            </div>
            <div id="old" style="display: none">
                <h4 class="form-header h4" >政策信息</h4>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">引流奖励：</label>
                            <div class="col-sm-8">
                                <select name="policyYlId" class="form-control m-b">
                                    <option value="">所有</option>
                                    <option th:each="oy:${oldYList}" th:text="${oy.policyName}" th:value="${oy.id}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">采购奖励：</label>
                            <div class="col-sm-8">
                                <select name="policyCgId" class="form-control m-b">
                                    <option value="">所有</option>
                                    <option th:each="oc:${oldCList}" th:text="${oc.policyName}" th:value="${oc.id}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">增量奖励：</label>
                            <div class="col-sm-8">
                                <select name="policyZlId" class="form-control m-b">
                                    <option value="">所有</option>
                                    <option th:each="oz:${oldZList}" th:text="${oz.policyName}" th:value="${oz.id}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:inline="javascript">
        var prefix = ctx + "team/teamYlInfo"
        $("#form-agentPosOperation-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-teamYl-add').serialize());
            }
        }

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        /**
         * 选择服务商
         */
        function selectTeamView() {
            var url =prefix+ "/selectTeamView";
            $.modal.open("选择服务商" , url, '1100',"500");
        }


        /**
         * 选择本级级以下代理
         */
        function selectAgentInfoRecursiveData() {
            var agentNum = $("#applyAgentNum").val();
            if ($.common.isEmpty(agentNum)){
                $.modal.alertWarning("请选择申请资深总监");
                return;
            }
            var url =prefix+ "/selectAgentInfoList?agentNum="+agentNum;
            $.modal.open("选择下级服务商" , url, '1100',"500");
        }



        /**
         * 选择类型
         */
        function selectOnchange(obj) {
            //DATE没有长度
            if (obj.value == '1'){
                $("#new").hide();
                $("#old").show();
            } else if (obj.value == '2'){
                $("#old").hide();
                $("#new").show();
            }
        }

    </script>
</body>
</html>